package com.c.ctgproject.adapter.review

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.c.ctgproject.R
import com.c.ctgproject.entity.review.PartReviewEntity
import com.c.ctgproject.utils.handlerNull

/**
 * 作者:LiBW
 * 创建日期: 2020/9/11
 * 描述:销售单详情页 车辆单独配件适配器
 */
class PartsChildAdapter(private val context: Context, private val mList: List<PartReviewEntity.DataBean.ListBean.PartsInfosBean>) : RecyclerView.Adapter<PartsChildAdapter.ViewHolder>() {
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val view = LayoutInflater.from(context).inflate(R.layout.activity_part_order_detail_child, parent, false)
        return ViewHolder(view)
    }

    override fun getItemCount(): Int {
        return mList.size
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val data = mList[position]
        holder.mPartNameTV.text = data.partsName.handlerNull()
        holder.mPriceTV.text = data.partsPrice.handlerNull()
        holder.mCountTV.text = data.partsNumber.handlerNull()
        holder.mWeightTV.text = data.partsWeight.handlerNull()
    }

    inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        val mPartNameTV: TextView = itemView.findViewById(R.id.mPartNameTV)
        val mPriceTV: TextView = itemView.findViewById(R.id.mPriceTV)
        val mCountTV: TextView = itemView.findViewById(R.id.mCountTV)
        val mWeightTV: TextView = itemView.findViewById(R.id.mWeightTV)
    }
}